import React from 'react';
import { Form, Input, Button } from 'antd';
import { UserOutlined, LockOutlined } from '@ant-design/icons';
import { useNavigate } from 'react-router-dom';
import styles from './login.module.css';
import { userLoginToken } from "../../store/token/userToken";

const Login = () => {
    const navigate = useNavigate();
    const onFinish = async (values) => {
        console.log('登录信息:', values);
        const code= await userLoginToken()
        // const inForData =await getUserInfoStore()
        // console.log(inForData)
        navigate('/')
        // TODO: 实现登录逻辑
    };

    return (
        <div className={styles.loginContainer}>
            <div className={styles.loginBox}>
                <h2>权限管理系统</h2>
                <Form
                    name="login"
                    onFinish={onFinish}
                    autoComplete="off"
                >
                    <Form.Item
                        name="username"
                        rules={[{ required: true, message: '请输入用户名!' }]}
                    >
                        <Input
                            prefix={<UserOutlined />}
                            placeholder="用户名"
                            size="large"
                        />
                    </Form.Item>

                    <Form.Item
                        name="password"
                        rules={[{ required: true, message: '请输入密码!' }]}
                    >
                        <Input.Password
                            prefix={<LockOutlined />}
                            placeholder="密码"
                            size="large"
                        />
                    </Form.Item>

                    <Form.Item>
                        <Button type="primary" htmlType="submit" block size="large">
                            登录
                        </Button>
                    </Form.Item>
                </Form>
            </div>
        </div>
    );
};

export default Login;
